/*
 * @Description:
 * @Author: chenjiaxin
 * @Date: 2022-06-07 21:10:48
 * @LastEditTime: 2022-06-07 21:25:36
 * @FilePath: \leetcode\2_队列结构\02_击鼓传花.js
 */
function findOne(nameList, num) {
  let queue = new Queue();
  // qu.enqueue("a")
  // qu.enqueue("b")
  // qu.enqueue("c")
  // qu.enqueue("d")
  // qu.enqueue("e")
  for (let index = 0; index < nameList.length; index++) {
    const element = nameList[index];
    queue.enqueue(element);
  }
  let i = 1;
  while (queue.size() > 1) {
    let item = queue.dequeue();
    if (i == num) {
      i = 1;
    } else {
      i++;
      queue.enqueue(item);
    }
  }

  return queue.dequeue();
}
